package lion.framework.core.web.path;

import java.util.List;

import lion.dev.lang.InterceptorAdaptor;

/**
 * 
 * 请求方法执行的拦截类，该拦截器在执行拦截任务时，将执行其他拦截器的方法
 * 
 * @author lion
 * @email hl_0074@sina.com
 * @date 2015年4月18日
 */
public class ExecuteInterceptor extends InterceptorAdaptor {

	List<InterceptorAdaptor> interceptors = ExecutorInterceptorManager.getInterceptors();

	@Override
	public boolean onBefore(Object... args) throws Exception {

		for (InterceptorAdaptor interceptor : interceptors) {
			if (!interceptor.onBefore(args)) { return false; }
		}

		return true;
	}

	@Override
	public void onException(Object... args) throws Exception {

		for (InterceptorAdaptor interceptor : interceptors) {
			try {
				interceptor.onException(args);
			} catch (Exception e) {
			}
		}
		throw (Exception) args[2];
	}

	@Override
	public void onPost(Object... args) throws Exception {

		for (InterceptorAdaptor interceptor : interceptors) {
			try {
				interceptor.onPost(args);
			} catch (Exception e) {
			}
		}
	}
}
